package com.liuyjy.encryptDecrypt;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @Author liuyjy
 * @Date 2025/2/20 12:48
 * @Description: 监控增强：
 **/
@Slf4j
@Aspect
@Component
public class CryptoMonitor {
    @Around("@annotation(EncryptDecrypt)")
    public Object monitor(ProceedingJoinPoint pjp) {
        long start = System.nanoTime();
        try {
            return pjp.proceed();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        } finally {
            log.info("crypto process time: {}", System.nanoTime() - start);
        }
    }
}
